<%-- 
    Document   : consulta_disciplina
    Created on : 02/11/2011, 12:38:33
    Author     : leonardo
--%>

<%@page import="java.sql.ResultSet"%>
<%@page import="java.util.Collections"%>
<%@page import="javax.swing.JOptionPane"%>
<%@page import="br.com.ufpb.halloc.comunicacao.Facade"%>
<%@page import="java.util.ArrayList"%>
<%@page import="br.com.ufpb.halloc.negocio.Disciplina"%>
<%@page import="java.util.List"%>
<%@page contentType="text/html" pageEncoding="UTF-8"%>
<!DOCTYPE html>
<html>
    <head>
        <meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
        <title></title>
        <style type="text/css">
            div#back {
                background-color: lightsteelblue;
                height: auto;
                margin-top: 0px;
                margin-left: 170px;
                margin-right: 170px;
            }
            div#form {
                background-color: #DDD;
                font: 14px Verdana, sans-serif;
                height: 60px;
                margin-top: 5px;
                border: 1px solid #696969;
                margin-left: 100px;
                margin-right: 100px;
            }
            
            div#campos, div#form {
                color: #333;
            }
                
            #tab_customizada
            {
                font-family:"Trebuchet MS", Arial, Helvetica, sans-serif;
                width:100%;
                border-collapse:collapse;
            }
            #tab_customizada td, #tab_customizada th 
            {
                font: 14px Verdana, sans-serif;
                border:2px solid #98bf21;
                padding:3px 7px 2px 7px;
                color: #000000;
            }
            #tab_customizada th 
            {
                font: 16px Verdana, sans-serif;
                text-align:center;
                padding-top:5px;
                padding-bottom:4px;
                background-color:#369;
                color:#fff;
            }
            #tab_customizada tr.alt td 
            {
                color:#000000;
                background-color: #EAF2D3;
            }

        </style>
        <script language="JavaScript" type="text/javascript">
            function confirmacao(id, nome){
                var opcao = confirm('Você tem certeza que deseja remover a Disciplina:\n' + nome + '?')
                if (opcao) {
                    window.self.location.href = "RemoveDisciplina.do?nome="+nome+"&codigo="+id;                    
                }
            }
        </script>
    </head>
    <body>
        <jsp:include page="menubarra.jsp"></jsp:include>        
        <br>
        <form action="ConsultaDisciplina.do" method="POST" id="consulta">
            <div id="back">
                <br>
                <div align="center">Consulta disciplina</div>
                <div id="form">
                    <br>
                    <table width="60%" align="center">
                        <tr>
                            <td><font size="4" face="arial"> Código: </font></td>
                            <td><input type="text" name="cod_disciplina" size="10"></td>
                            <td><font size="4" face="arial"> Nome: </font></td>
                            <td><input type="text" name="nome_disciplina" size="40"></td>
                        </tr>
                    </table>
                </div>
                <div align="center">
                    <br>
                    <table>
                        <tr>
                            <td colspan="2"><input type="submit" value="Consultar"></td>
                        </tr>
                    </table>
                </div>
            <br>
         <div align="center">
             <table id="tab_customizada" border="1">
                    <tr>
                        <th>Código</th>
                        <th>Nome</th>
                        <th>Créditos</th>
                        <th>Ações</th>
                    </tr>
<% //buscar disciplinas cadastradas
List<Disciplina> disciplinas = new ArrayList<Disciplina>();
        
        disciplinas = (List<Disciplina>) request.getAttribute("consulta");
        
        if (disciplinas != null) {
            for (Disciplina d : disciplinas) { %>
                <tr><td> <%=d.getID()%></td>
                <td><%=d.getNome()%></td>
                <td><%=d.getCreditos()%></td>
                <td>
                    <a href="#" onclick="window.open('AtualizaDisciplina.jsp?codigo=<%=d.getID()%>&nome=<%=d.getNome()%>&creditos=<%=d.getCreditos()%>&departamento=<%=d.getNumdpto()%>', 'Atualizar Disciplina', 'STATUS=NO, TOOLBAR=NO, LOCATION=NO, DIRECTORIES=NO, RESISABLE=NO, SCROLLBARS=YES, TOP=200, LEFT=400, WIDTH=500, HEIGHT=300');">
                        <img name="" src="imagens/atualizar.png" width="30" height="30" alt="atualiza"/>
                    </a>
                        <img name="" onclick="confirmacao('<%=d.getID()%>','<%=d.getNome()%>')" src="imagens/remover.png" width="30" height="30" alt="remove"/>
                </td>
              </tr>
<%          } // fim do for 
        } // fim do if   
%>  
             </table>
             <br>
    </body>
</html>
